package com.xyc.user.controller;

import com.xyc.user.entity.User;
import com.xyc.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/home")
    public String home() {
        return "home";
    }

    /**
     * @Author xyc
     * @Date 2017/9/10 10:51
     * @Description 获取用户信息
     */

    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session) {
        User user = (User) session.getAttribute("userinfo");
        return user;
    }

    /**
     * @Author xyc
     * @Date 2017/9/10/ 15:12
     * @Description 登出系统
     */
    @RequestMapping("/logout")
    public String logout(HttpSession session) {
        session.invalidate();
        return "login";
    }

}
